package com.bw.lib_log;

import com.bw.lib_log.impl.LogcatImpl;

/**
 * @ClassName Logger
 * @Author hu..
 * @Data 2024/7/22
 * @Description
 */
public class Logger {
    private Logger(){
    }

    private ILogger logger;

    public Logger(boolean isDebug,String tag,LoggerLevel level,LoggerType type){
        switch (type){

            case Logcat:
                logger=new LogcatImpl();
                break;
            case Server:
                throw new RuntimeException("no impl server,please wait...");
            case Email:
                throw new RuntimeException("no impl email,please wait...");

        }

        logger.setDebug(isDebug);
        logger.setLoggerLevel(level);
        logger.setLogTag(tag);
    }

    public void v(String tag,String log){
        logger.v(tag,log);
    }
    public void i(String tag,String log){
        logger.i(tag,log);
    }
    public void d(String tag,String log){
        logger.d(tag,log);
    }
    public void w(String tag,String log){
        logger.w(tag,log);
    }
    public void e(String tag,String log){
        logger.e(tag,log);
    }



    public static class Builder{

        private boolean isDebug=false;
        private String tag="123";
        private LoggerLevel level;

        private LoggerType loggerType;

        public Builder setDebug(boolean _debug){
            this.isDebug=_debug;
            return this;
        }

        public Builder setTag(String _tag){
            this.tag=_tag;
            return this;
        }

        public Builder setLevel(LoggerLevel _level){
            this.level=_level;
            return this;
        }

        public Builder setType(LoggerType _type){
            this.loggerType=_type;
            return this;
        }

        public Logger build(){
            return new Logger(isDebug,tag,level,loggerType);
        }

    }
}
